package service.StrategyService._driver;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import businesslogic.Strategybl.HotelStrategyController;
import org.junit.BeforeClass;
import org.junit.Test;

import VO.StrategyVO;
import service.StrategyService.HotelStrategyService;
import service.StrategyService._stub.HotelStrategyService_stub;
import util.Message;
import util.UserType;

import java.rmi.RemoteException;

public class HotelStrategyService_driver {
	
	static HotelStrategyService strategyService;
    @BeforeClass
    public static void before(){
        try {
            strategyService=new HotelStrategyService_stub();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
//        strategyService=new HotelStrategyController();
    }
    @Test
    public void getStrategyTest() throws RemoteException {
    	assertNotNull(strategyService.getStrategy("222").next());
    }
    @Test
    public void addNewStrategyTest() throws RemoteException {
        StrategyVO strategyVO1=new StrategyVO("insomnia",UserType.CLIENT,"双十一",0.6);
        assertEquals(Message.FAIL,strategyService.addNewStrategy(strategyVO1));
        StrategyVO strategyVO2=new StrategyVO("insomnia",UserType.WEBSITEMARKERER,"双十一",0.6);
        assertEquals(Message.SUCCESS,strategyService.addNewStrategy(strategyVO2));
        StrategyVO strategyVO3=new StrategyVO("insomnia",UserType.WEBSITEMARKERER,null,0.6);
        assertEquals(Message.NOT_COMPLETE,strategyService.addNewStrategy(strategyVO3));
    }
    @Test
    public void removeStrategyTest() throws RemoteException {
        StrategyVO strategyVO1=new StrategyVO("insomnia",UserType.CLIENT,"双十一",0.6);
        assertEquals(true,strategyService.removeStrategy(strategyVO1));
        assertEquals(false,strategyService.removeStrategy(null));
    }

}
